<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class OrderBatchLog extends Model
{
    use HasFactory,PimpableTrait,SoftDeletes;

    /**
     * 可搜索字段
     */
    public $searchable = [
        'created_at',
        'status',
        'type',
    ];

    /**
     * 可批量赋值字段
     */
    public $fillable = [
        'orders',
        'send',
        'send_success',
        'status',
        'type',
    ];

    /**
     * 强制转化类型字段
     */
    public $casts = [
        'orders' => 'array'
    ];

    /**
     * 表中的类型状态
     */
    // io批量处理类型
    public $orderBatchType = [
        'delete_order' => '批量删除订单',
        'manual_shipment' => '批量手动发货',
        'print_electronic_sheet' => '批量打印电子面单',
        'distribution' => '批量配送',
        'virtual_shipment' => '批量虚拟发货',
    ];

    // 批量处理状态
    public $orderBatchStatus = [
        'Untreated' => '未处理',
        'Processing' => '处理中',
        'Completed' => '已完成',
        'Failed' => '处理失败',
    ];

    /**
     * 可排序字段
     */
    public $sortable = ['created_at', 'id'];

    /**
     * 默认排序字段
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 关联的购物车
     */
    function order(){
        return $this->hasMany(Order::class,'order_id','id');
    }
}
